<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>原型链继承</title>
    <style>
        section {
            padding: 10px;
        }
    </style>
</head>

<body>
    <h1>原型链继承</h1>
    <section>
        <ul>
            <li>打通原型链</li>
        </ul>
    </section>

    <!-- 示例代码 -->
    <script>
        // 父类构造函数
        function Plane(color) {
            this.color = color;
        }
        Plane.prototype.fly = function () {
            console.log('flying');
        }

        // Fighter 构造函数
        function Fighter(color) {
            this.bullets = [];
        }
        // 原型链继承
        Fighter.prototype = new Plane('blue');
        // 特有方法
        Fighter.prototype.shoot = function () {
            console.log('biu biu biu');
        }

        // new 一个实例
        var fighter = new Fighter();

        // 调用属性和方法
        console.log(fighter.color);
        console.log(fighter.bullets);
        fighter.shoot();
        fighter.fly();

        // instanceof 判断
        fighter instanceof Fighter;
        fighter instanceof Plane;
    </script>
</body>

</html>